/*    */ package com.newcrm.businessarchives;
/*    */ 
/*    */ import com.newcrm.exception.CaptchaException;
/*    */ import com.newcrm.util.Util;
/*    */ import java.io.IOException;
/*    */ import java.io.PrintStream;
/*    */ import java.io.UnsupportedEncodingException;
/*    */ import java.net.URLEncoder;
/*    */ import java.util.Date;
/*    */ import java.util.HashMap;
/*    */ import java.util.Map;
/*    */ import org.apache.log4j.Logger;
/*    */ import org.jsoup.Connection;
/*    */ import org.jsoup.Jsoup;
/*    */ import org.jsoup.nodes.Document;
/*    */ import org.jsoup.nodes.Element;
/*    */ import org.jsoup.select.Elements;
/*    */ 
/*    */ public class ZhejiangSearchEngine extends SearchEngine
/*    */ {
/* 21 */   private static Logger logger = Logger.getLogger(ZhejiangSearchEngine.class
/* 22 */     .getName());
/*    */ 
/*    */   public ZhejiangSearchEngine(String name)
/*    */   {
/* 25 */     this.name = standardizedName(name);
/*    */   }
/*    */ 
/*    */   public static void main(String[] args)
/*    */     throws CaptchaException
/*    */   {
/* 33 */     ZhejiangSearchEngine searchEngine = new ZhejiangSearchEngine(
/* 34 */       "浙江临海煤矿机械厂");
/*    */ 
/* 36 */     Map items = searchEngine.getCompanyByWeb();
/* 37 */     System.out.println(items);
/*    */   }
/*    */ 
/*    */   protected Map<String, Object> getCompanyByWeb()
/*    */     throws CaptchaException
/*    */   {
/* 45 */     if (!isValid(this.name)) {
/* 46 */       return null;
/*    */     }
/* 48 */     String url = null;
/*    */     try {
/* 50 */       url = "http://wcm.zjaic.gov.cn/zjaic/wsbs/zxcx/qyjbxxcx/query!getCropInfoList.action?name=" + 
/* 51 */         URLEncoder.encode(this.name.trim(), "gb2312");
/*    */     } catch (UnsupportedEncodingException e) {
/* 53 */       url = "http://wcm.zjaic.gov.cn/zjaic/wsbs/zxcx/qyjbxxcx/query!getCropInfoList.action?name=" + this.name.trim();
/*    */     }
/*    */     try {
/* 56 */       Document doc = Jsoup.connect(url).userAgent("Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; GTB6.6; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; Tablet PC 2.0; .NET CLR 1.1.4322; .NET4.0C)")
/* 57 */         .timeout(10000).get();
/* 58 */       Elements links = doc.select("row");
/* 59 */       if ((links == null) || (links.size() == 0)) {
/* 60 */         return null;
/*    */       }
/*    */ 
/* 63 */       Element item = links.first();
/* 64 */       Map info = new HashMap();
/*    */ 
/* 66 */       info.put("CompanyName", item.attr("QYMC"));
/* 67 */       info.put("SN", item.attr("ZCH"));
/* 68 */       info.put("Header", item.attr("FDDBR"));
/* 69 */       info.put("FoundedDate", item.attr("CLRQ"));
/* 70 */       info.put("RegisteredCapital", 
/* 71 */         item.attr("ZCZB") + "万" + item.attr("BZ"));
/* 72 */       info.put("Address", item.attr("ZS"));
/* 73 */       info.put("OperatingPeriod", 
/* 74 */         item.attr("JYQSRQ") + " - " + item.attr("JYJZRQ"));
/* 75 */       info.put("BusinessScope", item.attr("JYFW"));
/* 76 */       info.put("UpdateDate", Util.date2Str(new Date()));
/*    */ 
/* 79 */       saveDB(info);
/* 80 */       return info;
/*    */     } catch (IOException e) {
/* 82 */       logger.warn("get company from web failed", e);
/*    */     }
/*    */ 
/* 85 */     return null;
/*    */   }
/*    */ }

/* Location:           C:\E\referenceProject\CRM参考\qikebao\WEB-INF\lib\qikebao.jar
 * Qualified Name:     com.newcrm.businessarchives.ZhejiangSearchEngine
 * JD-Core Version:    0.6.1
 */